home *** CD-ROM | disk | FTP | other *** search
/ HamCall (April 1991) / HAMCALL CD-ROM (Buckmaster)(April 1991).BIN / prgming / ctutor / readchar.c < prev    next >
Text File  |  1990-10-14  |  1KB  |  47 lines

  1.                                          /* Chapter 10 - Program 3 */
  2. #include "stdio.h"
  3.  
  4. main()
  5. {
  6. FILE *funny;
  7. char c;
  8.  
  9.    funny = fopen("TENLINES.TXT","r");
  10.  
  11.    if (funny == NULL) printf("File doesn't exist\n");
  12.    else {
  13.       do {
  14.          c = getc(funny);    /* get one character from the file */
  15.          putchar(c);         /* display it on the monitor       */
  16.       } while (c != EOF);    /* repeat until EOF (end of file)  */
  17.    }
  18.    fclose(funny);
  19. }
  20.  
  21.  
  22.  
  23. /* Result of execution
  24.  
  25. This is an example line.  Line number 1
  26. This is an example line.  Line number 2
  27. This is an example line.  Line number 3
  28. This is an example line.  Line number 4
  29. This is an example line.  Line number 5
  30. This is an example line.  Line number 6
  31. This is an example line.  Line number 7
  32. This is an example line.  Line number 8
  33. This is an example line.  Line number 9
  34. This is an example line.  Line number 10
  35. Additional lines.
  36. Additional lines.
  37. Additional lines.
  38. Additional lines.
  39. Additional lines.
  40. Additional lines.
  41. Additional lines.
  42. Additional lines.
  43. Additional lines.
  44. Additional lines.
  45.  
  46. */
  47.